import git from './git';
import { IOptions } from '../index';

export interface IOptionsWithUrl extends IOptions {
  httpUrl: string;
  sshUrl: string;
}

interface IData {
  // 仓库名称
  REPO_NAME: string;
  // 标签名称
  TAG: string;
  // 本项目的根目录
  ROOT: string;
  REPO_ROOT: string;
  options: IOptionsWithUrl;
}

process.on('message', async (data: IData) => {
  const { REPO_NAME, TAG, ROOT, REPO_ROOT, options } = data;
  Object.assign(process.env, { REPO_NAME, TAG, ROOT, REPO_ROOT });
  await git(options);
});